package com.humngyang;


import com.humngyang.com.hmy.study.concurrency.myannoations.filter.HttpFilter;
import com.humngyang.com.hmy.study.concurrency.myannoations.filter.HttpIntercepter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


@MapperScan("com.humngyang.com.hmy.mapper")
@SpringBootApplication
public class App extends WebMvcConfigurationSupport{
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    @Bean
    public FilterRegistrationBean httpFilter() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new HttpFilter());
        //要拦截的那些请求
        filterRegistrationBean.addUrlPatterns("/threadlocal/*");
        return filterRegistrationBean;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new HttpIntercepter()).addPathPatterns("/**");
    }
}
